package com.kingyea.mobilepolice.apimanage.providerservicehost.service.impl;

import com.kingyea.mobilepolice.apimanage.providerservicehost.bean.ProviderServiceHost;
import com.kingyea.mobilepolice.apimanage.providerservicehost.dao.ProviderServiceHostMapper;
import com.kingyea.mobilepolice.apimanage.providerservicehost.service.ProviderServiceHostService;
import com.kingyea.mobilepolice.apimanage.utils.page.PageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author Mr.Lin
 * @version v1.0.0
 * @description ProviderServiceHost 实现类
 * @date Created in 2018-05-19 16:13:25
 */
@Service
@Transactional
public class ProviderServiceHostServiceImpl implements ProviderServiceHostService {

    private static final Logger LOGGER = LoggerFactory.getLogger(ProviderServiceHostServiceImpl.class);

    @Resource
    private ProviderServiceHostMapper providerServiceHostMapper;

    /**
     * 通过ID查找对象
     *
     * @param hostSerialNo
     * @return
     */
    @Override
    public ProviderServiceHost getById(String hostSerialNo) throws Exception {
        return this.providerServiceHostMapper.getById(hostSerialNo);
    }

    /**
     * 列表
     *
     * @param
     * @return
     */
    @Override
    public List<ProviderServiceHost> list(ProviderServiceHost providerServiceHost) throws Exception {
        List<ProviderServiceHost> list = providerServiceHostMapper.list(providerServiceHost);
        return list;
    }

    /**
     * 删除
     *
     * @param hostSerialNo
     * @return
     */
    @Override
    public int deleteById(String hostSerialNo) throws Exception {
        providerServiceHostMapper.deleteById(hostSerialNo);
        return 1;
    }

    /**
     * 保存
     *
     * @param providerServiceHost
     * @return
     */
    @Override
    public ProviderServiceHost save(ProviderServiceHost providerServiceHost) throws Exception {
        try {
            providerServiceHostMapper.save(providerServiceHost);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return providerServiceHost;
    }

    /**
     * 更新
     *
     * @param providerServiceHost
     * @return
     */
    @Override
    public ProviderServiceHost update(ProviderServiceHost providerServiceHost) throws Exception {
        try {
            providerServiceHostMapper.update(providerServiceHost);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return providerServiceHost;
    }

    @Override
    public Object searchByCondition(Map<String, Object> map) throws Exception {
        PageInfo.startPage(map);
        return PageInfo.getPageInfo(providerServiceHostMapper.searchByCondition(map));
    }


}
